<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="${basePath}">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="semantic/semantic.css" rel="stylesheet" type="text/css">
<link href="static/css/allot.css" rel="stylesheet" type="text/css">
<link href="static/css/teacher.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="static/css/style.css" />
<!-- jquery一定要在semantic之前导入 -->
<script src="static/js/jquery-1.12.4.js" type="text/javascript"></script>
<script src="semantic/semantic.js" type="text/javascript"></script>
<script src="static/js/student.js" type="text/javascript"></script>
<script type="text/javascript">	
function ajax(params) {

	var xmlhttp;
	//判断XMLHttpRequest是否存在
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
	} else {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}

	//readystate监听事件
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
			//输出响应的结果
			console.log("aaaa" + xmlhttp);
			if (params.callback) {
				params.callback(xmlhttp);
			}
		}
	};

	//取出method参数
	var method = params.method ? params.method : "GET";
	var asynch = params.asynch ? params.asynch : true;

	//打开一个连接
	xmlhttp.open(method, params.url, asynch);
	//判断是否POST请求
	if (method.toLowerCase() == 'post') {
		//post请求一定要设置这句话
		xmlhttp.setRequestHeader("Content-Type",
				"application/x-www-form-urlencoded");
	}

	//判断请求是否有参数
	if (params.params) {
		//params.params = {"userName":"张三"，"gender":"男"};
		//转换成userName=张三&gengder=男
		var p = [];
		for (key in params.params) {
			p.push(key + "=" + params.params[key]);
		}
		xmlhttp.send(p.join("&"));
	} else {
		xmlhttp.send(null);
	}
}

//JQuery入口
$(function() {
	$('#addf').on('click',
					function() {
						var staid = document.getElementById("staid").value;
						var stuid = document.getElementById("stuid").value;
						ajax({
							url : "follow/insert?staid=" + staid +"&stuid="+stuid,
							method : "GET",
							callback : function(xmlhttp) {
								var data;
								if (window.JSON) {
									data = JSON.parse(xmlhttp.response);
									if(data > 0){
										var mo = $("#follow");
										mo.modal('show');
									}
									else{
										var mo = $("#notfollow");
										mo.modal('show');
									}
									var stuid = $(".stuid");
									stuid.val(data);
								} else {
									alert("data");
									data = eval("(" + xmlhttp.response + ")");
								}
								if (data) {
									stuname.innerText = data;
									alert("data");
								}

							}
						});

					});
});

	function cooperation(a){
		var s = a;
		var input = $(".input");
		input.val(a);
		var inputtwo = $(".inputtwo");
		inputtwo.val("newcoop");
		var mo = $("#cooperation");
		mo.modal('show');
	}
	function twoallot(a){
		var s = a;
		var input = $(".studentid");
		input.val(a);
		var inputtwo = $(".inputtwo");
		inputtwo.val("newcoop");
		var mo = $("#anginallot");
		mo.modal('show');
	}
	function nossuysu(){
		var mo = $("#anginallot");
		mo.modal('hide');
	}
	function nocooperation(){
		var mo = $("#cooperation");
		mo.modal('hide');
	}
	function follow(a){
		var s = a;
		var input = $(".stuid");
		input.val(a);
		var mo = $("#follow");
		mo.modal('show');
	}	
	function nofollow() {
		var mo = $("#follow");
		mo.modal('hide');
	}
	
	function notfollow() {
		var mo = $("#notfollow");
		mo.modal('hide');
	}
</script>
<title>客户信息</title>
</head>
<body>
	<div class="gps">
		<a class="home" href="staff?method=forward">首页</a> <i
			class="right chevron icon divider"></i> <a href="allot/manager">分配学员</a>
		<i class="right chevron icon divider"></i> <a
			href="allot/student?staffid=${studentPo.studentAllotId}">学员列表</a>
	</div>
	<hr />
	<div id="header">
		客户：<span>${studentPo.studentName}</span> 创建日期：<span>${studentPo.studentComedate}</span>
		所在班级：<span>${clazz}</span> &nbsp;&nbsp;&nbsp;&nbsp;
		<c:if test="${empty cmethod}">
			<c:if test="${empty clazz&&not empty total_student_id}">
				<a onclick="fenban(${studentPo.studentId})" id="fenfen"> <i
					class="external share icon"></i><span
					class="label label-success radius">分班</span>
				</a>
			</c:if>
			<c:if test="${not empty clazz}">
				<a onclick="fenban(${studentPo.studentId})" id="fenfen"> <i
					class="external share icon"></i><span
					class="label label-success radius">转班</span>
				</a>
			</c:if>

			<c:if test="${ empty total_student_id}">
				<a href="student?method=update&id=${studentPo.studentId}"> <i
					class="edit icon"></i><span class="label label-success radius">修改</span></a>
			</c:if>
		</c:if>
		<c:if test="${studentPo.studentAllotId eq schid}">
			<a onclick="twoallot(${studentPo.studentId})"> <i
				class="external share icon"></i> <span
				class="label label-success radius">转分</span>
			</a>
			<a onclick="cooperation(${studentPo.studentId})"> <i
				class="reply all icon"></i><span class="label label-success radius">协作</span></a>
		</c:if>
		<br> <br> 咨询师：<span>${studentPo.staffName}</span> 协作师：<span>
			<c:forEach items="${cooperationsPoList}" var="datas">
		${ datas.cooperationsName}&nbsp;&nbsp;
		</c:forEach>
		</span>
	</div>
	<hr />
	<div id="content">
		<div id="title">基本信息：</div>
		<table>
			<tbody>
				<tr>
					<td>性别：</td>
					<td id="td">${studentPo.sexText}</td>
					<td>Q Q：</td>
					<td id="td">${studentPo.studentQq}</td>
					<td>联系电话：</td>
					<td id="td">${studentPo.studentPhone}</td>
				</tr>
				<tr>
					<td>家长：</td>
					<td id="td">${studentPo.studentParent}</td>
					<td>住址：</td>
					<td id="td">${studentPo.studentAddress}</td>
					<td>家长电话：</td>
					<td id="td">${studentPo.studentParentPhone}</td>
				</tr>
				<tr>
					<td>学历：</td>
					<td id="td">${studentPo.studentRecode}</td>
					<td>来源：</td>
					<td id="td">${studentPo.sourceName}</td>
					<td>兴趣程度：</td>
					<td id="td">${studentPo.interestingName}</td>
					<td>是否交款：</td>
					<c:if test="${empty clazz}">
						<td id="td">否</td>
					</c:if>
					<c:if test="${not empty clazz}">
						<td id="td">是</td>
					</c:if>
				</tr>
			</tbody>
		</table>
	</div>
	<hr />
	<div id="newfollow">
		<span id= "addf"> <i
			class="add circle icon"></i><span class="label label-success radius">新增跟进</span>
		</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;下次跟进时间:
		<c:forEach items="${FollowPoList}" var="followPo">
			<span id="schagaintime">${followPo.followAgainTime}</span>
		</c:forEach>

	</div>
	<div id="followcontent">
		<c:forEach items="${FollowPoList}" var="followPo">
			<div class="ui info message">
				<div class="header" id="followcont">
					<c:if test="${schid eq followPo.followStaffId}">
						<a
							href="follow/update?stuid=${followPo.followStudentId}&staffid=${followPo.followStaffId}&followid=${followPo.followId}">
							<i class="edit icon"></i>
						</a>
					</c:if>
					跟进人：<span>${ followPo.followStaffName}</span> 方式：<span>${ followPo.followStyle}</span>
					日期：<span>${ followPo.followTime}</span>
					<c:if test="${empty followPo.followRead}">
					未批阅
					</c:if>
					<c:if test="${!empty followPo.followRead}">
					批阅：<span>${ followPo.followRead}</span>
					</c:if>

				</div>
				<br> 跟进内容：<span id="content">${ followPo.followContent}</span>
			</div>
			<br />
		</c:forEach>
	</div>
	<!--弹出层  -->
	<div class="ui modal" id="cooperation">
		<div class="header">请求协作</div>
		<div class="teacher-content">
			<c:set var="test" value="newcoop"></c:set>
			<div id="allotselect">
				<form id="" method="get" action="allot/one">
					<input type="hidden" class="inputtwo" name="cmethod"> <input
						type="hidden" name="staffid" value="${staffid }"> <input
						type="hidden" class="input" name="stuid"> <label>分配给:</label>
					<select name="coopstaffid">
						<c:forEach items="${StaffList}" var="staffPo">
							<option value="${staffPo.staffId}">${staffPo.staffName }
						</c:forEach>
					</select> <br>
					<div id="cooperationbt">
						<div class="ui black deny button" onclick="nocooperation()">取消请求</div>
						<button style="border-style: none;">
							<div class="ui positive right labeled icon button"
								onclick="allot()">
								确认请求 <i class="checkmark icon"></i>
							</div>
						</button>
					</div>
				</form>
			</div>
		</div>
	</div>
<!-- 新增跟进记录的弹出窗 -->
	<div class="ui modal" id="follow">
		<div class="header">跟进记录</div>
		<div class="teacher-content" id="schfollow">
			<c:set var="test" value="newcoop"></c:set>
			<form method="post" action="follow/insert">
				<input type="hidden" class="stuid" name="stuid" id = "stuid" value="${studentPo.studentId}"> 
				<input type="hidden" name="staffid" value="${staffid}" id = "staid">
				<div class="ui input focus">
					<label>跟进方式:</label> <input type="text" name="followStyle"
						placeholder="跟进方式">
				</div>
				<br>
				<div class="ui input focus">
					<label>下次跟进:</label> <input type="text" placeholder="下次跟进时间"
						name="followAgainTime" onfocus="HS_setDate(this)">
				</div>
				<br>
				<div class="field">
					<textarea cols="33" rows="10" name="followContent"
						placeholder="跟进内容"></textarea>
				</div>
				<br>
				<div class="actions">
					<div class="ui black deny button" onclick="nofollow()">取消新增</div>
					<button style="border-style: none;">
						<div class="ui positive right labeled icon button"
							onclick="allot()">
							确认新增 <i class="checkmark icon"></i>
						</div>
					</button>
				</div>
			</form>
		</div>
	</div>
<!-- 无权限新增跟进记录的弹出窗 -->
	<div class="ui modal" id="notfollow">
		<div class="header">跟进记录</div>
		<span>权限不够</span>
		<br>
		<div class="ui black deny button" onclick="notfollow()">取消新增</div>
	</div>

	<div id="fenban">
		<iframe class="thickframe" id="thickframe" marginwidth="0"
			marginheight="0" frameborder="1" scrolling="no"
			style="width: 100%; height: 1162px;"> </iframe>
		<div class="thickdiv" id="thickdiv"
			style="width: 100%; height: 1162px;"></div>
		<div class="thickbox" id="thickbox"
			style="left: 500.5px; top: 180px; width: 402px; height: 202px;">
			<div class="thickwrap" style="width: 760px;">
				<div class="thicktitle" id="" style="width: 740">
					<span>分班</span>
				</div>
				<div class="thickcon" id=""
					style="width: 400px; height: 200px; padding-left: 20px; padding-right: 20px;">
					<div id="addressDiagDiv">
						<div class="m" id="edit-cont">
							<div>
	<!-- 	<span id="xxx">x</span> -->
							</div>
							<c:if test="${not empty clazz }">
								<form action="group?method=update" onsubmit="return check()"
									method="post">

									<input type="hidden" value="" id="fenid" name="studentId">
									<div id="claz">
										<label style="width: 200px; height: 30px;">班级</label> <select
											name="clazz" style="width: 200px; height: 30px;">
											<c:forEach items="${listclazz }" var="cla">
												<option value="${cla.clazzId}"
													${param.clazz==cla.clazzId?'selected':'' }>${cla.clazzName }</option>
											</c:forEach>
										</select>
									</div>
									<div class="ui positive  button" id="save">
										<button>保存</button>
									</div>
									<div class="ui button" id="close">取消</div>

								</form>
							</c:if>
							<c:if test="${empty clazz }">
								<form action="group?method=insert" onsubmit="return check()"
									method="post">

									<input type="hidden" value="" id="fenid" name="studentId">
									<div id="claz">
										<label style="width: 200px; height: 30px;">班级</label> <select
											name="clazz" style="width: 200px; height: 30px;">
											<c:forEach items="${listclazz }" var="cla">
												<option value="${cla.clazzId}"
													${param.clazz==cla.clazzId?'selected':'' }>${cla.clazzName }</option>
											</c:forEach>
										</select>
									</div>
									<div class="ui positive  button" id="save">
										<button>保存</button>
									</div>
									<div class="ui button" id="close">取消</div>
								</form>
							</c:if>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<!-- 转分配的弹出层 -->
	<div class="ui modal" id="anginallot">
		<i class="close icon"></i>
		<div class="header">转分配给</div>
		<form method="post" action="student/allot">
			<input type="hidden" class="studentid" name="ids"> <input
				type="hidden" class="studentid" name="ifallot" value="staffid">
			<div id="allotselect">
				<select name="staffid">
					<c:forEach items="${StaffList}" var="staffPo">
						<option value="${staffPo.staffId}">${staffPo.staffName }
					</c:forEach>
				</select>
			</div>
			<div class="actions">
				<div class="ui black button" onclick="nossuysu()">取消</div>
				<button>
					<div class="ui positive right labeled icon button">
						确认转发 <i class="checkmark icon"></i>
					</div>
				</button>
			</div>
		</form>
	</div>
</body>
</html>